package jiekou;
import java.util.*;

class PersonSortable implements Comparable<PersonSortable>
{
	private String name;
	private int age;
	PersonSortable(String name,int age)
	{
		this.name=name;
		this.age=age;
	}
	public String toString()
	{
		return name+"-"+age;
	}
	@Override
	public int compareTo(PersonSortable p)
	{
		if(name.compareTo(p.name) == 0)
		{
			return age - p.age;
		}
		else
		{
			return name.compareTo(p.name);
		} 
	}
}
public class Main {

	public void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			PersonSortable[] P=new PersonSortable[n];
			for(int i=0;i<n;i++)
			{
				P[i]=new PersonSortable(in.nextLine(),in.nextInt());
			}
			for(int i=0;i<n;i++)
			{
				System.out.println(P[i]);
			}
			System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
		}

	}

}



